
<UserControl x:Class="WebAppUploader.UploadToIISControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:vsfx="clr-namespace:Microsoft.VisualStudio.Shell;assembly=Microsoft.VisualStudio.Shell.10.0"
             xmlns:local="clr-namespace:WebAppUploader"
             mc:Ignorable="d" 
             d:DesignHeight="500" d:DesignWidth="800"
             HorizontalAlignment="Stretch"
             VerticalAlignment="Stretch"
             HorizontalContentAlignment="Stretch"
             VerticalContentAlignment="Stretch"
             Width="Auto"
             Height="Auto"
             Name="UploadToIIS"
             IsEnabled="{Binding Enabled}"
             Background="{DynamicResource {x:Static vsfx:VsBrushes.ToolWindowBackgroundKey}}"
             >
    <UserControl.Resources>
        <Style
            TargetType="Button">
            <Setter
                Property="Margin"
                Value="2" />
            <Setter
                Property="Background"
                Value="{DynamicResource {x:Static vsfx:VsBrushes.ButtonFaceKey}}"
                />
        </Style>
    </UserControl.Resources>
    <Grid>
        
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <local:ToggleButtonBar ItemsSource="{Binding ProjectModel.Profiles}" 
                 SelectedValue="{Binding ProjectModel.CurrentProfile, Mode=TwoWay}"
                 SelectedValuePath="Name"
                 >
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Border
                        CornerRadius="2"
                        BorderThickness="1"
                        BorderBrush="{DynamicResource {x:Static vsfx:VsBrushes.ActiveBorderKey }}"
                        Padding="2"
                        MinWidth="75"
                        >
                        <TextBlock Text="{Binding Name}" TextAlignment="Center" />
                    </Border>                    
                </DataTemplate>
            </ListBox.ItemTemplate>
        </local:ToggleButtonBar>
        <Button Grid.Column="1" Command="{Binding ProjectModel.ConfigCommand}">Edit Profiles</Button>
        <Grid Grid.Row="1" Grid.ColumnSpan="2">
            
            <Grid.RowDefinitions>
                <RowDefinition
                    Height="Auto" />
                <RowDefinition/>
                <RowDefinition
                    Height="Auto" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition
                    Width="5" />
                <ColumnDefinition
                    />
            </Grid.ColumnDefinitions>
            <StackPanel Orientation="Horizontal"
                >
                <Button
                    Content="Select All"
                    Command="{Binding ProjectModel.SelectedProfile.SelectCommand}"
                    CommandParameter="true"
                    IsEnabled="{Binding ProjectModel.SelectedProfile.CanUpload}"
                    HorizontalAlignment="Left" />
                <Button
                    Content="Deselect All"
                    Command="{Binding ProjectModel.SelectedProfile.SelectCommand}"
                    CommandParameter="false"
                    IsEnabled="{Binding ProjectModel.SelectedProfile.CanUpload}"
                    HorizontalAlignment="Left" />
                
                <local:ToggleButtonBar x:Name="showList" SelectionChanged="showList_SelectionChanged">
                    <ListBoxItem>Modified</ListBoxItem>
                    <ListBoxItem>All</ListBoxItem>
                </local:ToggleButtonBar>
                
            </StackPanel>                
            <StackPanel Grid.Column="2" Orientation="Horizontal"
                HorizontalAlignment="Right">
                <Button
                    Content="Upload"
                    Command="{Binding ProjectModel.SelectedProfile.UploadCommand}"
                    IsEnabled="{Binding ProjectModel.SelectedProfile.CanUpload}"
                    HorizontalAlignment="Left" />
                <Button
                    Content="Refresh"
                    Command="{Binding ProjectModel.SelectedProfile.RefreshCommand}"
                    IsEnabled="{Binding ProjectModel.SelectedProfile.CanUpload}" />
            </StackPanel>    
            <ListView
                ItemsSource="{Binding ProjectModel.SelectedProfile.Files}"
                x:Name="fileListView"
                Grid.Row="1">
                <ListView.Resources>
                    <Style
                        TargetType="{x:Type ListViewItem}">
                        <Style.Triggers>
                            <DataTrigger
                                Binding="{Binding Dirty}"
                                Value="true">
                                <Setter
                                    Property="Background"
                                    Value="#50adff2f" />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </ListView.Resources>
                <ListView.View>
                    <GridView>
                        <GridViewColumn>
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <CheckBox
                                        IsChecked="{Binding Dirty, Mode=TwoWay}" />
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn
                            Header="File"
                            DisplayMemberBinding="{Binding FileName}" />
                        <GridViewColumn
                            Header="Path"
                            DisplayMemberBinding="{Binding RelativePath}" />
                    </GridView>
                </ListView.View>
            </ListView>
            <GridSplitter
                HorizontalAlignment="Stretch"
                Name="gridSplitter1"
                ShowsPreview="True"
                ResizeDirection="Columns"
                Grid.Column="1"
                Grid.RowSpan="1"
                Grid.Row="1" />
            

            <ListView
                ItemsSource="{Binding ProjectModel.SelectedProfile.Parts}"
                Grid.Column="2"
                Grid.Row="1">
                <ListView.View>
                    <GridView>
                        <GridViewColumn
                            DisplayMemberBinding="{Binding PartID}"
                            Header="Part" />
                        <GridViewColumn
                            DisplayMemberBinding="{Binding Host}"
                            Header="Host" />
                        <GridViewColumn
                            Width="200"
                            Header="Progress">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <Grid>
                                        <ProgressBar
                                            Value="{Binding Progress}"
                                            Maximum="100"
                                            Width="180"
                                            Height="20" />
                                    </Grid>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                    </GridView>
                </ListView.View>
            </ListView>

            <StatusBar Grid.Row="3"
                Grid.ColumnSpan="3">
                <StatusBarItem
                    Content="{Binding ProjectModel.SelectedProfile.Status}" />
            </StatusBar>


        </Grid>
    </Grid>
    
</UserControl>